package com.boil.qz.safekavass.repository;

import com.boil.qz.safekavass.model.WeixinAccessToken;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.Modifying;
import org.springframework.data.jpa.repository.Query;

/**
 * Created by ChenYong on 2017-07-04.
 * <br>
 * 微信凭证实体仓库。
 */
public interface WeixinAccessTokenRepository extends JpaRepository<WeixinAccessToken, Long> {
    /**
     * 更新凭证到期。
     */
    @Modifying(clearAutomatically = true)
    @Query(value = "UPDATE TB_WEIXIN_ACCESS_TOKEN T SET T.EXPIRES_CODE = 1 WHERE T.EXPIRES_CODE = 0", nativeQuery = true)
    public void updateExpires();
}